from django.conf.urls.defaults import *
from django.views.generic import date_based
from django.views.generic.list_detail import object_list

from apps.blog.models import Entry, Category
from apps.blog.views import category_detail
from apps.tagging.views import tagged_object_list

entry_info_dict = {
    'queryset': Entry.live.all(),
    'date_field': 'published_on',
}
 
category_info_dict = {
    'queryset': Category.objects.all(),
}

urlpatterns = patterns('',
    url(r'^$', date_based.archive_index, entry_info_dict, name='entry_archive_index'),
    url(r'^(?P<year>\d{4})/$', date_based.archive_year, entry_info_dict, name='entry_archive_year'),
    url(r'^(?P<year>\d{4})/(?P<month>\w{3})/$', date_based.archive_month, entry_info_dict, name='entry_archive_month'),
    url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/$', date_based.archive_day, entry_info_dict, name='entry_archive_day'),
    url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$', date_based.object_detail, dict(entry_info_dict, slug_field='slug'), name='entry_detail'),
    url(r'^category/$', object_list, category_info_dict, name='category_list'),
    url(r'^category/(?P<slug>[-\w]+)/$', category_detail, name='category_detail'),
    url(r'^tag/(?P<tag>[^/]+(?u))/$', tagged_object_list, dict(model=Entry, paginate_by=10, allow_empty=True, template_name='blog/tag_detail.html')),
)